package name.jiaosha.air.company.domain;
import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import name.jiaosha.air.user.domain.LoginUser;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * The persistent class for the company database table.
 * 
 * @author BEA Workshop
 */
@Entity()
@Table(name="company")
public class Company  implements Serializable {
	//default serial version id, required for serializable classes.
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String name;
	private java.util.Set<CarInfo> carInfos;
	private java.util.Set<Department> departments;
	private java.util.Set<Employee> employees;
	private java.util.Set<LoginUser> loginUsers;
	private java.util.Set<Storage> storages;

    public Company() {
    }

	@Id()
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="id", unique=true, nullable=false, precision=11)
	public Integer getId() {
		return this.id;
	}
	public void setId(Integer id) {
		this.id = id;
	}

	@Basic()
	@Column(name="name", length=50)
	public String getName() {
		return this.name;
	}
	public void setName(String name) {
		this.name = name;
	}

	//bi-directional many-to-one association to CarInfo
	@OneToMany(mappedBy="company", fetch=FetchType.LAZY)
	public java.util.Set<CarInfo> getCarInfos() {
		return this.carInfos;
	}
	public void setCarInfos(java.util.Set<CarInfo> carInfos) {
		this.carInfos = carInfos;
	}

	//bi-directional many-to-one association to Department
	@OneToMany(mappedBy="company", fetch=FetchType.LAZY)
	public java.util.Set<Department> getDepartments() {
		return this.departments;
	}
	public void setDepartments(java.util.Set<Department> departments) {
		this.departments = departments;
	}

	//bi-directional many-to-one association to Employee
	@OneToMany(mappedBy="company", fetch=FetchType.LAZY)
	public java.util.Set<Employee> getEmployees() {
		return this.employees;
	}
	public void setEmployees(java.util.Set<Employee> employees) {
		this.employees = employees;
	}

	//bi-directional many-to-one association to LoginUser
	@OneToMany(mappedBy="company", fetch=FetchType.LAZY)
	public java.util.Set<LoginUser> getLoginUsers() {
		return this.loginUsers;
	}
	public void setLoginUsers(java.util.Set<LoginUser> loginUsers) {
		this.loginUsers = loginUsers;
	}

	//bi-directional many-to-one association to Storage
	@OneToMany(mappedBy="company", fetch=FetchType.LAZY)
	public java.util.Set<Storage> getStorages() {
		return this.storages;
	}
	public void setStorages(java.util.Set<Storage> storages) {
		this.storages = storages;
	}

	public boolean equals(Object other) {
		if (this == other) {
			return true;
		}
		if (!(other instanceof Company)) {
			return false;
		}
		Company castOther = (Company)other;
		return new EqualsBuilder()
			.append(this.getId(), castOther.getId())
			.isEquals();
    }
    
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
    }   

	public String toString() {
		return new ToStringBuilder(this)
			.append("id", getId())
			.toString();
	}
}